#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ls (p<<1)
#define rs ((p<<1)+1)
#define mid ((c[p].l+c[p].r)>>1)
#define getchar() (p1 == p2 && (p2 = (p1 = buf1) + fread(buf1, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf1[1 << 23], *p1 = buf1, *p2 = buf1, ubuf[1 << 23], *u = ubuf;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],to,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++to]=48+x%10;while(to) pc(stk[to--]);}
}
using namespace IO;
const int N = 5e5+10;
int n,k,a[N],ans,L[N],R[N],x,y,v[N],o;
priority_queue<pair<int,int> >p;
signed main()
{
	freopen("sub.in","r",stdin);
//	freopen("sub.out","w",stdout);
	read(n),read(k);
	for(int i = 1;i <= n;i++) read(a[i]),L[i] = i-1,R[i] = i+1;
	R[n] = 1; L[1] = n;
	for(int i = 1;i <= n;i++) p.push(make_pair(a[i]+a[R[i]],i));
	for(int i = n;i > k;i--)
	{
		while(1)
		{ 
			o = p.top().second;
			if(v[o] || v[R[o]] || a[o]+a[R[o]] != p.top().first) p.pop();
			else break;
		}
		if(a[o] > a[R[o]])
		{
			v[o] = 1; p.push(make_pair(a[L[o]]+a[R[o]],L[o]));
			R[L[o]] = R[o];
			L[R[o]] = L[o];
		}
		else
		{
			o = R[o];
			v[o] = 1; p.push(make_pair(a[L[o]]+a[R[o]],L[o]));
			R[L[o]] = R[o];
			L[R[o]] = L[o];
		}
		p.pop();
	}
	while(1)
	{ 
		o = p.top().second;
		if(v[o] || v[R[o]] || a[o]+a[R[o]] != p.top().first) p.pop();
		else break;
	}
	print(p.top().first);
	flush();
	return 0;
}

